package com.shanghaionstar.nav.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.onstar.cn.common.util.DeviceUtil;
import com.onstar.cn.framework.annotation.FindViewById;
import com.onstar.cn.framework.base.CommonAdapter;
import com.onstar.cn.framework.base.CommonViewHolder;
import com.onstar.cn.sqlite.entities.PoiSearchHistory;
import com.onstar.cn.ripple.view.RippleCustomBtn;
import com.shanghaionstar.R;
import com.shanghaionstar.nav.presenter.NavSetAddressPresenter;

import java.util.List;

public class NavPoiSearchHistoryNoTbtAdapter extends CommonAdapter<PoiSearchHistory> {
    private Context context;
    private List<PoiSearchHistory> historyOrFavoriteInfoLists;
    private PoiSearchHistory poiSearchHistorys;

    private NavSetAddressPresenter navSetAddressPresenter;

    public NavPoiSearchHistoryNoTbtAdapter(List<PoiSearchHistory> datas, Context context, NavSetAddressPresenter navSetAddressPresenter) {
        super(datas, context);
        this.context = context;
        this.historyOrFavoriteInfoLists = datas;
        this.navSetAddressPresenter = navSetAddressPresenter;
    }

    @Override
    public void getView(final int position, CommonViewHolder viewHolder) {
        ViewHolder holder = (ViewHolder) viewHolder;
        poiSearchHistorys = new PoiSearchHistory();
        poiSearchHistorys = historyOrFavoriteInfoLists.get(position);

        if (DeviceUtil.getLanguage().equalsIgnoreCase("en")) {
            holder.btn_sendtbt.setTextSize(12f);
        } else {
            holder.btn_sendtbt.setTextSize(14f);
        }
        holder.btn_sendtbt.setVisibility(View.GONE);
        holder.text_vendor_name.setText(poiSearchHistorys.getName());
        holder.text_vendor_addres.setText(poiSearchHistorys.getAddress());
    }


    public CommonViewHolder getViewHolder() {
        return new ViewHolder();
    }

    @Override
    public int layoutId() {
        return R.layout.nav_history_fav_listview_item;
    }

    private class ViewHolder extends CommonViewHolder {
        @FindViewById(R.id.text_vendor_name)
        TextView text_vendor_name;
        @FindViewById(R.id.text_vendor_addres)
        TextView text_vendor_addres;
        @FindViewById(R.id.btn_sendtbt)
        RippleCustomBtn btn_sendtbt;
    }
}
